Fix: incorrect ~1 decoding in decode_pointer_inplace#1019
Open
CyberpsychoJacob wants to merge 2 commits into
Open
Fix: incorrect ~1 decoding in decode_pointer_inplace#1019CyberpsychoJacob wants to merge 2 commits into
CyberpsychoJacob wants to merge 2 commits into
Conversation
The ~1 escape sequence (RFC 6901 JSON Pointer, representing '/') was writing the decoded '/' to decoded_string[1] instead of decoded_string[0], leaving the original '~' in place and producing '~/' instead of '/'. This caused any JSON Patch operation whose path contained a ~1 sequence to silently target the wrong key, making ADD/REMOVE/REPLACE/MOVE/COPY operate on an incorrect node without error.
Verifies that cJSONUtils_ApplyPatches correctly resolves ~1 escape sequences in patch paths to a literal '/' when targeting object keys that contain a forward slash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug:
decode_pointer_inplaceincJSON_Utils.cincorrectly decoded the~1escape sequence (RFC 6901 JSON Pointer, representing
/).The write target was off by one:
This left the original ~ in place, producing ~/ instead of /. As a
result, any JSON Patch operation (add, remove, replace, move, copy)
whose "path" contained a ~1 sequence would silently target the wrong key.
Fix:
Changed decoded_string[1] to decoded_string[0] so the decoded / is
written to the correct position.
A unit test has been added to tests/misc_utils_tests.c that applies a
replace patch targeting a key with a literal / in its name via a ~1
path, and verifies the correct key is updated.